package com.gouldzd.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.gouldzd.constant.MessageConstant;
import com.gouldzd.entity.Result;
import com.gouldzd.pojo.Setmeal;
import com.gouldzd.service.SetMealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/*
 * @Author zhangdan
 * @Description //TODO 套餐管理
 * @Date 18:02 2020/5/2
 * @Param 
 * @return 
 **/
@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Reference
    private SetMealService setMealService;

    //查询所有套餐
    @RequestMapping("/getAllSetmeal")
    public Result getAllSetmeal(){

        try {
            List<Setmeal> list = setMealService.findAll();
            return new Result(true, MessageConstant.GET_SETMEAL_COUNT_REPORT_SUCCESS,list);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_SETMEAL_COUNT_REPORT_FAIL);
        }
    }

    //根据套餐id查询套餐详情(包括套餐基本信息,套餐包含的检查组,检查组包含的检查项)
    @RequestMapping("/findById")
    public Result findById(Integer id){

        try {
            Setmeal setmeal = setMealService.findById(id);
            return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_SETMEAL_FAIL);
        }

    }

}
